<template>
  <div class="t_page">
    <div class="t_page2">
      <div class="t_nav">
        <h1>问题回复编辑页</h1>
      </div>
      <div class="t_info">
        <div class="asker">
          <p>提问人：{{ wtData.username }}</p>
          <span>
            {{ wtData.wtwnr }}
          </span>
        </div>
        <div class="t_info_div1">

          <div class="mage">
            <textarea v-model="wtData.whfnr" placeholder="" rows=1 cols=40 class="input"
                      onfocus="window.activeobj=this;this.clock=setInterval(function(){activeobj.style.height=activeobj.scrollHeight+'px';});"
                      onblur="clearInterval(this.clock);"></textarea>

          </div>
        </div>
      </div>
      <div class="t_button">
        <div>
          <a href="#" class="but" @click="back">取消</a>
          <a href="#" class="but" @click="pt">确认回复</a>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "AnswerEditor",
  data(){
    return{
      wtData: {},
      textarea: ''
    }
  },
  methods: {
    pt(){
      this.wtData.wwtzt = 1
      this.wtData.whfr = JSON.parse(window.localStorage.getItem("userInfo")).id
      this.$axios({
        url: '/wtzx/add',
        method: "post",
        data: this.wtData
      }).then(res=>{
        if (res.data){
          this.$router.replace("/askAndAnswer")
        } else {
          this.$message.error("失败")
        }
      })
    },
    back(){
      this.$router.replace("/askAndAnswer")
    }
  },
  created() {
    this.wtData = this.$route.params.item
  }
}
</script>
<style src="../css/InformEditor.css" scoped></style>
<style scoped>
.input{
  width: 100%;
  background-color: transparent;
  transform: translateX(-40px);
  min-height: 400px;
  border: none;
  outline: none;
  font-size: 18px;
  line-height: 30px;
  overflow: hidden;
}
.asker{
  border-radius: 10px;
  margin-bottom: 10px;
  padding: 5px 20px 20px 20px;
  background-color: #EEEEEE;
  font-size: 20px;
  font-weight: 600;
}
</style>

